//
//  CXChannelCollectionViewCell.m
//  ProjectOfBStage
//
//  Created by cuixin on 15/11/13.
//  Copyright © 2015年 cuixin. All rights reserved.
//

#import "CXChannelCollectionViewCell.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
@implementation CXChannelCollectionViewCell
-(void)dealloc{
    [_imgView release];
    [_titleLable release];
    [_backView release];
    [_channelModel release];
    [_bigBackView release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.imgView = [[UIImageView alloc] init];
        self.titleLable = [[UILabel alloc] init];
        self.backView = [[UIView alloc] init];
        self.bigBackView = [[UIView alloc] init];

        self.backView.backgroundColor= [UIColor blackColor];
        self.backView.alpha = 0.5;
        [self.titleLable setTextColor:[UIColor whiteColor]];
        [self.titleLable setFont:[UIFont boldSystemFontOfSize:HEIGHT_PRO(14)]];
        
//        self.bigBackView.layer.cornerRadius = 5;
//        self.bigBackView.layer.masksToBounds = YES;

        [self.bigBackView addSubview:self.imgView];
        [self.backView addSubview:self.titleLable];

        [self.bigBackView addSubview:self.backView];
        [self.contentView addSubview:self.bigBackView];
        
        [_imgView release];
        [_titleLable release];
        [_backView release];
        [_bigBackView release];

    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    self.bigBackView.frame = CGRectMake(WIDTH_PRO(5), 0, self.frame.size.width - WIDTH_PRO(5), self.frame.size.height);
    self.imgView.frame = CGRectMake(0, 0, self.bigBackView.frame.size.width, self.bigBackView.frame.size.height);
    self.backView.frame = CGRectMake(self.imgView.frame.origin.x, self.imgView.frame.size.height - HEIGHT_PRO(20), self.imgView.frame.size.width, HEIGHT_PRO(20));
    self.titleLable.frame = CGRectMake(0, 0, self.backView.frame.size.width, self.backView.frame.size.height);
}



-(void)setChannelModel:(ChannerModel *)channelModel{
    if (_channelModel != channelModel) {
        [_channelModel release];
        _channelModel = [channelModel retain];
    }
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:channelModel.pic] placeholderImage:[UIImage imageNamed:@"wait.png"]];
    self.titleLable.text = channelModel.name;
}
@end
